package com.zlx.ssm.service.impl;

import com.mchange.v2.lang.ObjectUtils;
import com.zlx.ssm.mapper.EmployeeInfoMapper;
import com.zlx.ssm.model.EmployeeInfo;
import com.zlx.ssm.service.IEmpolyteService;
import com.zlx.ssm.vo.AddUserInfo;
import com.zlx.ssm.vo.DateInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class EmpolyteServiceImpl implements IEmpolyteService {


    @Autowired
    private EmployeeInfoMapper employeeInfoMapper;

    @Override
    public void AddAdimn(DateInfo dateInfo) throws Exception {

        log.info("测试添加数据    :"+ dateInfo);

        EmployeeInfo employeeInfo = employeeInfoMapper.selectEmploByNameNot(dateInfo.getName());

        if (employeeInfo != null ) {
            throw new Exception("账户存在");
        }

        EmployeeInfo employeeInfo1 = new EmployeeInfo();

        employeeInfo1.setBirthday(dateInfo.getBirthday());
        employeeInfo1.setCity(dateInfo.getCity());
        employeeInfo1.setName(dateInfo.getName());
        employeeInfo1.setPasswrod(dateInfo.getPasswrod());
        employeeInfo1.setRoleName(dateInfo.getRoleName());
        employeeInfo1.setSex(dateInfo.getSex());


        employeeInfoMapper.intsertEployee(employeeInfo1);


    }

    public int selectAll(){

        int i = employeeInfoMapper.selectByPrimaryKeyNot();
        return i;
    }
}
